home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9496 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: realtime.net!usenet
  2. From: brian_d@sheshunoff.com
  3. Newsgroups: comp.lang.c++
  4. Subject: C++ error in borland, is this a compiler bug?
  5. Date: 1 Mar 1996 22:15:59 GMT
  6. Organization: Sheshunoff Information Services Inc.
  7. Message-ID: <4h7suv$760@news2.realtime.net>
  8. NNTP-Posting-Host: apm1-179.realtime.net
  9. X-RTcode: d75e2566311f65e16937779a
  10. X-Newsreader: SPRY News 3.03 (SPRY, Inc.)
  11.  
  12. I am using borland C++4.52, and OWL.  Owl has very little to do with this, though.
  13. GetModule() returns a TModule *.  TModule has a member function LoadString that returns
  14. a string object.  string class has a member function c_str() that return a char * to the actual string.
  15.  
  16.         BOOL newInstl;
  17.         long pgmDirSpace;
  18.  
  19.  
  20. I get the following error when trying to compile the following (modified for example)
  21. "Destructor for string required in conditional expression in function ..."
  22.  
  23.  
  24.     pgmDirSpace=newInstl ? atol((GetModule()->LoadString(ROOM_NEW)).c_str())
  25.                            : atol((GetModule()->LoadString(ROOM_OVER)).c_str());
  26.  
  27.  
  28. But if I change it to this, it works fine.
  29.     if(newInstl) pgmDirSpace=atol((GetModule()->LoadString(ROOM_NEW)).c_str());
  30.     else pgmDirSpace=atol((GetModule()->LoadString(ROOM_OVER)).c_str());
  31.  
  32. This will also compile fine.  Thrown in for example only.
  33.     switch(newInstl)
  34.     {
  35.     case TRUE;
  36.     pgmDirSpace=atol((GetModule()->LoadString(ROOM_NEW)).c_str());
  37.     break;
  38.  
  39.     default:
  40.     atol((GetModule()->LoadString(ROOM_OVER)).c_str());
  41.     }
  42.  
  43.  
  44. I dont see any difference that should matter in any of these examples.
  45. I obviously have a workaround, but I am also very currious.
  46. Thanks for any answers to this mystery :o) !
  47.     Brian
  48.